<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
	</head>
	<body>
		<script>
			// ============================== 父类 ==============================
			function parentFun(_name, _job) { // 动态原型模式
				this.name = _name;
				this.job = _job;
				parentFun.prototype.clearAll = function() {
					console.log('父类技能：教书，写代码');
				}
			}
			// ============================== 子类 ==============================
			function formData(_name, _job, _skill) {
				parentFun.call(this, _name, _job); // 对象冒充继承父类属性值
				this.skill = _skill;
				this.testFun = function() {};
				formData.prototype.clearAll = function() { // 原型继承父类方法，扩展skill到父类
					console.log('子类技能： ' + this.skill.substr(3, 5));
				}
			}
			formData.prototype = new parentFun();
			// ============================== 实例 ==============================
			var person = new formData('小明', ['教师', '程序员'], '教书，写代码');
			var person2 = new formData('小明', ['教师', '程序员'], '教书，写代码');

			console.log(person);
			console.log(person.testFun == person2.testFun); // falsze
			console.log(person.clearAll == person2.clearAll); // true
			console.log(person.hasOwnProperty('job')) // true
			console.log(person.hasOwnProperty('clearAll')) // false
			console.log(person instanceof formData) // true
			console.log(person instanceof parentFun) // true
			person.clearAll(); // 子类技能：写代码
		</script>
	</body>
</html>